﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;

namespace GMS
{
    public partial class Pages_StoneSelectionInfo : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                LoadStoneandCostDetails();
            }
           
        }

        private void LoadStoneandCostDetails()
        {
            DAL.Stone s = BLL.Common.GetStoneById(SessionVariable.Instance.UserDetails.Options.StoneId);
            DAL.StoneCategory sCategory = BLL.Common.GetStoneCategoryById(SessionVariable.Instance.UserDetails.SelectedStoneCategoryId);
            DAL.StoneType sType = BLL.Common.GetStoneTypeById(SessionVariable.Instance.UserDetails.SelectedStoneTypeId);

            if (s != null)
            {
                imgSelectedStone.ImageUrl = s.ImagePath;
                lblStoneName.Text = s.Name;
                lblOrigin.Text = s.Origin;
                lblThickNess.Text = s.Thickness;

                double cost = s.Price * SessionVariable.Instance.UserDetails.Cost.Surface;
                lblCounterTopeEstimate.Text = cost.ToString("F2"); 
            }

            if (sCategory != null)
            {
                lblPriceGroup.Text = sCategory.Name;
            }

            if (sType != null)
            {
                lblStoneType.Text = sType.Name;
            }
        }

        protected void btnBack_Click(object sender, EventArgs e)
        {
            Response.Redirect("SelectColor.aspx");
        }

        protected void btnNext_Click(object sender, EventArgs e)
        {
            if (SessionVariable.Instance.UserDetails.IsDataPersisted)
            {
                Response.Redirect("Estimate.aspx");
            }
            else
            {
                if (SessionVariable.Instance.UserDetails.Cost.Edge > 0)
                {
                    Response.Redirect("SelectEdge.aspx");
                }
                else
                {
                    Response.Redirect("SinkOptions.aspx");
                }
            }
        }
    }
}